package com.ecomm.exception.struts;

import com.ecomm.util.Logger;
import org.apache.commons.logging.Log;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * User: hou wanchun
 * Date: 2003-5-29
 * Time: 14:35:54
 * <p/>
 * 用来给struts处理没有登陆异常的句柄
 */
public class NoLoginExceptionHandler extends ExceptionHandler
{
    private static Log log = Logger.getLog(NoLoginExceptionHandler.class);

    public ActionForward execute(Exception e, ExceptionConfig exceptionConfig, ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServletException
    {
        log.info("来自" + request.getRemoteHost() + "用户没有登陆就试图访问路径是" + request.getRequestURI() + "资源。");
        return actionMapping.findForward("login");
    }

}
